<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * YB Board Class
 *
 * Board library for Code Igniter.
 *
 * @author		Yashpal Bharadwaj
 * @version		0.5
 * @link		http://
 * @license		MIT License Copyright (c) 2009 Yashpal Bharadwaj
 * @credits		http://
 */

class YB_Actions {

    function YB_Actions() {
        $this->ci =& get_instance();

        log_message('debug', 'YB Actions Libary Initialized');

        // Load required library
        $this->ci->load->library('Session');
        $this->ci->load->database();

        //Load models
        $this->ci->load->model(array('board/Thread_model','board/Post_model'));


        // Load YB Board config
        $this->ci->load->config('yb_board');

        // Load language
        //$this->ci->lang->load('dx_auth');

        // Load  event
        //$this->ci->load->library('DX_Auth_Event');

        // Initialize
        $this->_init();
    }

	/* Private function */

    function _init() {
    // Init helper config variable



        $this->YB_can_guest_browse =$this->ci->config->item('YB_can_guest_browse');
        $this->YB_can_view_board   =$this->ci->config->item('YB_can_view_board');
        $this->YB_can_view_forum   =$this->ci->config->item('YB_can_view_forum');
        $this->YB_can_view_category=$this->ci->config->item('YB_can_view_category');
        $this->YB_can_view_thread  =$this->ci->config->item('YB_can_view_thread');
        $this->YB_enable_similies  =$this->ci->config->item('YB_enable_similies');
        $this->YB_view_online      =$this->ci->config->item('YB_view_online');
        $this->YB_view_memberlist  =$this->ci->config->item('YB_view_memberlist');
        $this->YB_view_board_stat  =$this->ci->config->item('YB_view_board_stat');

        //grab value from session
        $this->DX_user_id           =$this->ci->session->userdata('DX_user_id');
        $this->DX_username          =$this->ci->session->userdata('DX_username');
        $this->DX_role_id           =$this->ci->session->userdata('DX_role_id');
        $this->DX_role_name         =$this->ci->session->userdata('DX_role_name');
        $this->DX_parent_roles_id   =$this->ci->session->userdata('DX_parent_roles_id');
        $this->DX_parent_roles_name =$this->ci->session->userdata('DX_parent_roles_name');
        $this->DX_permission        =$this->ci->session->userdata('DX_permission');
        $this->DX_parent_permissions=$this->ci->session->userdata('DX_parent_permissions');
        $this->DX_logged_in         =$this->ci->session->userdata('DX_logged_in');
    }



    /**
     * Threads CRUD Operations
     * @return <type>
     */

    function create_thread() {
        return $this->ci->Thread_model->create_thread();
    }

    /**
     *In Edit make sure accroding to permissionuser can edit
     * normal user - content
     * mode/gmod/admin can lock, annoucement, hide the threads.
     * @return <type> 
     */
    function edit_thread() {
        return $this->ci->Thread_model->edit_thread();
    }

    function delete_thread() {
        return $this->ci->Thread_model->delete_thread();
    }

    function manage_threads() {
        return $this->ci->Thread_model->manage_threads();
    }

 
    /**
     * Posts/replies CRUD Operations
     * @return <type> 
     */
    function create_reply() {
        return $this->ci->Post_model->create_reply();
    }

    function edit_post() {
        return $this->ci->Post_model->edit_post();
    }

    function delete_post() {
        return $this->ci->Post_model->delete_post();
    }

    function manage_posts() {
        return $this->ci->Post_model->manage_posts();
    }



}
?>